#include "middlegroupattributingsetdlg.h"
#include "ui_middlegroupattributingsetdlg.h"

MiddleGroupAttributingSetDlg::MiddleGroupAttributingSetDlg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::MiddleGroupAttributingSetDlg)
{
    ui->setupUi(this);
    
    connect(ui->namelineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateOKBtn(QString)));
    connect(ui->describelineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateOKBtn(QString)));
    
    connect(ui->cancelBtn, SIGNAL(clicked(bool)), this, SLOT(close()));
    connect(ui->OKBtn, SIGNAL(clicked(bool)), this, SLOT(getAttributeData()));
    connect(ui->OKBtn, SIGNAL(clicked(bool)), this, SLOT(accept()));
}

MiddleGroupAttributingSetDlg::~MiddleGroupAttributingSetDlg()
{
    delete ui;
}

void MiddleGroupAttributingSetDlg::updateOKBtn(const QString text)
{
    if(!text.isEmpty())
        ui->OKBtn->setEnabled(true);
    if(ui->namelineEdit->text().isEmpty() && ui->describelineEdit->text().isEmpty())
        ui->OKBtn->setEnabled(false);
}

void MiddleGroupAttributingSetDlg::getAttributeData()
{
    name = ui->namelineEdit->text();
    describe = ui->describelineEdit->text();
}
